/*
 * RenzoScene.h
 *
 *  Created on: Aug 30, 2009
 *      Author: sonhua
 */

#ifndef RENZOSCENE_H_
#define RENZOSCENE_H_

#include "RenzoMustHave.h"

namespace Renzo {
	class RENZODERER_API Scene {
	public:
		Scene();
		virtual ~Scene();

		void loadFromFile(const char* file);
		void parseCollada(FILE* f);
		void parseMd2(FILE* f);

	/*
	 Scene graph
	 */
	public:
		SceneNode* add(Mesh* m);
		SceneNode* add(Camera* c);
		SceneNode* add(Light* l);
		void	 add(SceneNode* n);
		/*
		 Attach the scene with the root of a scene graph. Use this function when load scene from a scene file. E.g., Collada scene file
		 */
		void attach(SceneNode* root);
	private:
		SceneNode* root;	// scene graph root

	public:
		/**
		 Transfer all geometry to hardware
		 */
		void copyToHardware();

		/**
		 Set up all rendering contexts (camera, culling, etc.)
		 */
		virtual void render();
		virtual void update(int delta);
	

	/*
	 Maintain a list of cameras to view the scene
	 */
	private:		
		typedef std::vector<Camera*> CameraList;
		CameraList cameras;
		Camera*	activeCamera;
	public:
		void setActiveCamera(Camera* c);
		/**
		 Automatically set active camera to be the first camera node found in the scene graph
		 */
		void setActiveCameraAuto();
		Camera* getActiveCamera() const;
	};
}

#endif /* RENZOSCENE_H_ */
